<!DOCTYPE html>
<meta charset="utf-8">
<meta name="timeout" content="long">
<title>CSS Display: reading-flow with value grid-order and display: contents elements</title>
<link rel="help" href="https://drafts.csswg.org/css-display-4/#reading-flow">
<link rel="author" title="Di Zhang" href="mailto:dizhangg@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src='../../resources/shadow-dom.js'></script>
<script src="../../resources/focus-utils.js"></script>

<style>
.wrapper {
  display: grid;
  reading-flow: grid-order;
}
</style>

<div class="test-case" data-expect="order1,order2,order3,order4"
     data-description="Items in display contents are sorted in same grid container.">
  <div class="wrapper">
    <div style="display: contents">
      <button id="order3" style="order: 3">Order 3</button>
      <button id="order1" style="order: 1">Order 1</button>
      <div style="display: contents">
        <button id="order4" style="order: 4">Order 4</button>
        <button id="order2" style="order: 2">Order 2</button>
      </div>
    </div>
  </div>
</div>

<div class="test-case" data-expect="order1B,order2B,order3B,order4B,div1B,div2B"
     data-description="Items in display contents are sorted in same grid container, with focusable display contents divs at the end of the focus sequence.">
  <div class="wrapper">
    <div id="div1B" style="display: contents" tabindex="0">
      <button id="order3B" style="order: 3">Order 3</button>
      <button id="order1B" style="order: 1">Order 1</button>
      <div id="div2B" style="display: contents" tabindex="0">
        <button id="order4B" style="order: 4">Order 4</button>
        <button id="order2B" style="order: 2">Order 2</button>
      </div>
    </div>
  </div>
</div>

<script>
runFocusTestCases();
</script>
